<% layout('/layouts/default.html', {title: '提单查询', libs: ['validate','fileupload','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text('提单详情')}
                <% if (hasPermi('logistics:ladingbill:ladingBill:edit')){ %>
                    <button type="button" class="btn btn-primary" id="editView">${text('编辑单据')}</button>
                <% } %>
				<% if (hasPermi('financial:billnegotiated:billNegotiated:edit') && ladingBill.paymentMethod != "3"){ %>
				<button type="button" class="btn btn-primary" id="goBillNegotiated"> ${text('到单押汇')}</button>
				<% } %>
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${ladingBill}" action="${ctx}/logistics/ladingbill/ladingBill/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="ladingBillId" id="ladingBillId"/>
                <div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('单据编号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="ladingBillCode" maxlength="100" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('到单提醒')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="arrivalReminderCode" items="${listArrivalReminder}"
                                itemLabel="arrivalReminderCode" itemValue="arrivalReminderId" blankOption="true" class="form-control " disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('提单号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="ladingBillNumber" maxlength="100" class="form-control required" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('提单日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="date" readonly="true" maxlength="20" class="form-control" disabled="true"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('银行到单日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="bankArrivalDate" readonly="true" maxlength="20" class="form-control" disabled="true"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('保单号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="policyNumber" maxlength="100" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('服务订单')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="serviceOrderId" items="${listServiceOrder}"
                                itemLabel="serviceOrderCode" itemValue="serviceOrderId" blankOption="true" class="form-control " disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('国内资方')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="investorId" items="${listSupplier}"
                                itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control " disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('客户名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="customerId" items="${listCustomer}"
                                itemLabel="customerName" itemValue="customerId" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('供货外商')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="supplierId" items="${listSupplier}"
                                itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control " disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('外商名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="foreignBusinessmenId" items="${listSupplier}"
                                itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control " disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('付款方式')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="paymentMethod" dictType="payment_method" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
                <div class="form-unit">${text('国际物流信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('运输公司')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="transportCompany" items="${listTransportSupplier}"
                                itemLabel="supplierName" itemValue="supplierId" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('运输方式')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="transportMethod" dictType="erp_transport_type" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('起运港')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="fromPort" dictType="erp_harbor_list" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('目的港')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="toPort" dictType="erp_harbor_list" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('预计起航时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="estimatedFromDate" readonly="true" maxlength="20" class="form-control required" disabled="true"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('预计到港时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="estimatedToDate" readonly="true" maxlength="20" class="form-control required" disabled="true"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('实际起航时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="actualFromDate" readonly="true" maxlength="20" class="form-control" disabled="true"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('实际到港时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="actualToDate" readonly="true" maxlength="20" class="form-control" disabled="true"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('箱型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="boxModel" maxlength="100" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('箱量')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="boxQty" maxlength="100" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('箱号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="boxNumber" maxlength="100" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
                <div class="form-unit">${text('车辆信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('数量')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="qty" class="form-control digits" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
                <div class="ml10 mr10">
                    <table id="ladingBillDetailDataGrid"></table>
                </div>
                <div class="form-unit">${text('附件信息')}</div>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-2">
                                <span class="required hide">*</span> ${text('图片上传')}：</label>
                            <div class="col-sm-10">
                                <#form:fileupload id="uploadImage" bizKey="${ladingBill.id}" bizType="ladingBill_image"
                                uploadType="image" class="" readonly="true" preview="true"/>
                            </div>
                        </div>
                    </div>
                </div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('附件上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${ladingBill.id}" bizType="ladingBill_file"
									uploadType="all" class="" readonly="true" preview="true"/>
							</div>
						</div>
					</div>
				</div>
                <div class="form-unit">${text('系统信息')}</div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="createDate" class="form-control" disabled="true"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="createBy" class="form-control" disabled="true"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="updateDate" readonly="true" maxlength="20" class="form-control"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="updateBy" readonly="true" maxlength="20" class="form-control"/>
                            </div>
                        </div>
                    </div>
                </div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
//初始化提单明细DataGrid对象
$("#ladingBillDetailDataGrid").dataGrid({

	data: ${toJson(ladingBill.ladingBillDetailList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'ladingBillDetailId', editable:true, hidden:true},
		{header:'${text("服务订单行号")}', name:'rowNumber', hidden:true, width:150, editable:true, edittype:'text', editoptions:{'class':'form-control digits'}},
        {header:'${text("车辆")}', name:'tcar.carName', width:300, editable:false, edittype:'text'},
        {header:'${text("车型")}', name:'model', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("外币价格")}', name:'price', width:100, editable:true, edittype:'text', editoptions:{'class':'form-control number'}},
		{header:'${text("车架号")}', name:'frameNumber', width:100, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("发动机号")}', name:'engineNumber', width:100, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("生产日期")}', name:'productionDate', width:150, 
			formatter:'date', formatoptions:{srcformat:'Y-m-d',newformat:'Y-m-d'},
			editable:true, edittype:'text', editoptions:{'class':'form-control laydate required', 'readonly':'true',
				dataInit: function(element){
					laydate.render({elem:element, type:'date', format:'yyyy-MM-dd'});
				}
			}
		},
		{header:'${text("原厂地")}', name:'factory', width:100, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control required'}},
		{header:'${text("轮胎尺寸")}', name:'tireSize', width:100, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control required'}},
		{header:'${text("座位数")}', name:'seatNumber', width:100, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control required'}},
		{header:'${text("许可证号")}', name:'permitNumber', width:100, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("提单ID")}', name:'ladingBillId.ladingBillId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', hidden: true}
	],
	
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#ladingBillDetailDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {ladingBillDetailId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据
	
	// 编辑表格的提交数据参数
	editGridInputFormListName: 'ladingBillDetailList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,ladingBillDetailId,rowNumber,carId,model,price,frameNumber,engineNumber,productionDate,factory,tireSize,seatNumber,permitNumber,ladingBillId.ladingBillId,', // 提交数据列表的属性字段
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});

$('#goBillNegotiated').click(function () {
	let ladingBillId = $("#ladingBillId").val();
	window.location.href = "${ctx}/financial/billnegotiated/billNegotiated/goBillNegotiated?ladingBillId=" + ladingBillId;
})
</script>

<script>
    $("#editView").click(function () {
        var id = $("#ladingBillId").val();
        var URL = '${ctx}/logistics/ladingbill/ladingBill/form?ladingBillId=' + id;
        window.location.href =URL;
    });
</script>



